﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server; 
using System.Collections.Generic;
 
using RabbitMQ.Client;
using SHKF.B2C.UpdateStock;
using System.Net;
using System.IO;
using System.Text;

public partial class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void P_B2C_Update_Stock(SqlString url, 　
                                        SqlString WarehousSN, 
                                        SqlInt64 ProductSN, 
                                        SqlInt32 Qty,   
                                        SqlInt32 Forward,
                                        SqlInt32 Rubric,
                                        SqlString Summary,
                                        SqlString Memo)
    {
        try
        {
            // 在此处放置代码
            string strUrl = url.Value + "?";　
            strUrl += "WarehousSN=" + WarehousSN.Value;
            strUrl += "&ProductSN=" + ProductSN.Value;
            strUrl += "&Qty=" + Qty.Value;
            strUrl += "&Forward=" + Forward.Value;
            strUrl += "&Rubric=" + Rubric.Value;
            strUrl += "&Summary=" + Summary.Value;
            strUrl += "&Memo=" + Memo.Value;
             
            try
            { 
                string result = HttpHelp.Get(strUrl);
                SqlContext.Pipe.Send(result);
            }
            catch (Exception ex)
            {
                SqlContext.Pipe.Send(ex.InnerException.Message);
            }
          

            //using (SqlConnection con = new SqlConnection("context connection=true"))
            //{

            //    con.Open();

            //    //SqlCommand com = new SqlCommand(

            //    //    string.Format("insert into stores values('{0}','{1}')", stor_id, stor_name), con);

            //    //com.ExecuteNonQuery();
            //    con.Close();
            //}

            //var factory = new ConnectionFactory
            //   {
            //       HostName = "123.60.51.150", //ip
            //       Port = 5672, // 端口
            //       UserName = "admin", // 账户
            //       Password = "admin", // 密码
            //       VirtualHost = "/"   // 虚拟主机
            //   };

            //IConnection  connection = factory.CreateConnection(); 
          
        }
        catch (Exception ex)
        {
            SqlContext.Pipe.Send(ex.Message);
        }
        
    }
};
